package cn.iocoder.yudao.module.pay.wechat.convert;

import cn.iocoder.yudao.framework.business.basic.convert.SimpleMapperConvert;
import cn.iocoder.yudao.module.api.infrastructure.wechat.vo.WechatOrderDetailVO;
import cn.iocoder.yudao.module.pay.splitting.pojo.bo.PaySplittingBO;
import cn.iocoder.yudao.module.pay.wechat.pojo.po.WechatOrderInfo;
import cn.iocoder.yudao.module.pay.wechat.pojo.vo.WechatOrderInfoVO;
import org.mapstruct.Mapper;

/**
 * <pre>
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 * 对象转换器
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 * </pre>
 *
 * @author 山野羡民（1032694760@qq.com）
 * @since 2025/07/22
 */
@Mapper
public interface WechatOrderInfoConvert extends SimpleMapperConvert<WechatOrderInfoVO, WechatOrderInfo> {
    WechatOrderInfoConvert INSTANCE = org.mapstruct.factory.Mappers.getMapper(WechatOrderInfoConvert.class);

    default WechatOrderInfo convert(String payNo, WechatOrderDetailVO result) {
        WechatOrderInfo wechatOrderInfo = new WechatOrderInfo();
        wechatOrderInfo.setPayNo(payNo);
        wechatOrderInfo.setTransactionId(result.getTransactionId());
        wechatOrderInfo.setOrderState(result.getOrderState());
        wechatOrderInfo.setPaidAmount(result.getPaidAmount());
        wechatOrderInfo.setErrorMsg(result.getErrorMsg());
        wechatOrderInfo.setRawData(result.getRawData());
        return wechatOrderInfo;
    }

    default PaySplittingBO convert(WechatOrderInfo order) {
        if (order == null) {
            return null;
        }
        PaySplittingBO paySplittingBO = new PaySplittingBO();
        paySplittingBO.setPayNo(order.getPayNo());
        paySplittingBO.setSplitAmount(order.getPaidAmount());
        return paySplittingBO;
    }

}
